<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
    <title>比较任务列表</title>
	<link rel="stylesheet" type="text/css" href="/static/basic/plugins/easyui/themes/bootstrap/easyui.css">
	<link href="/static/basic/plugins/fontawesome-free-5.15.4-web/css/all.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="/static/m.css" >
	
</head>
<body>
<div id="window-mmask" class="window-mmask" ><div class="window-mmask-msg" >页面加载中,请稍候...</div></div>
<div class="easyui-layout" data-options="fit:true"  >
	<div data-options="region:'center'" >
		<table id="gridList" ></table>
	</div>
</div>
<div id="searchbar">
<div class="maction">
		<a href="javascript:void(0)" id="addRowButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-plus mbutton'">新增行</a>
		<a href="javascript:void(0)" id="removeButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-trash-alt mbutton color-c5'">删除</a>
		<a href="javascript:void(0)" id="saveButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-save mbutton'">保存</a>
		<a href="javascript:void(0)" id="btnDetail" class="easyui-linkbutton" data-options="plain:true,iconCls:'mbutton'">任务明细</a>
</div>
<form id="searchForm" >
	查询列<input id="search-compareConfigId" name="compareConfigId" class="easyui-textbox" >
	<a id="searchButton" href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-search mbutton'" >查询</a>
</form>
</div>
<script src="/static/basic/plugins/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="/static/basic/plugins/easyui/jquery.easyui.min.js"></script>
<script src="/static/basic/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
<script src="/static/extensions/jquery.jdirk.js"></script>
<script src="/static/extensions/jeasyui.extensions.base.loading.js"></script>
<script src="/static/init.js"></script>
<script src="/static/searchEdit.js"></script>
<!-- <script src="/static/basic/plugins/moment/moment.min.js"></script> -->
<script>
var options={
	page_id:"395044881453940736",
	grid_id:"gridList",
	sqlname:"grid_395044881453940736_excel_compare_task",
	showCheckbox:false,
	rownumbers:false,
};
var editRow=null;
//document ready
$(function(){
	grid1=new uniontrip.datagrid.searchEdit(options);
	//tab
	$('#addButton').bind('click', function(){
		editRow=null;
		EditDialog.dialog('setTitle','新增').dialog('open');
	});//新增行绑定事件
	$('#editButton').bind('click',function(){
		gridSelectRow(grid1.grid,function(row){
			editRow=row;
			EditDialog.dialog('setTitle','修改').dialog('open');
		});
	});//编辑按钮绑定事件
	$('#removeButton').bind('click',onDeleteRow);//删除行绑定事件
	
	$('#searchButton').bind('click',grid1.load);//查询操作绑定事件
	//row
	$('#addRowButton').bind('click', addRow);//新增行绑定事件
	$('#btnDetail').bind('click',taskDetail);//编辑按钮绑定事件
	//$('#removeButton').bind('click',grid1.remove);//删除行绑定事件
	$('#saveButton').bind('click', grid1.accept);//保存datagrid绑定事件
	//$('#cancelEditButton').bind('click',grid1.cancelEditing);//取消行编辑绑定事件
	//$('#endEditingButton').bind('click', grid1.endEditing);//结束行编辑绑定事件
	//$('#rejectButton').bind('click', grid1.rejectChanges);//撤销编辑绑定事件		
    //$('#showChangesButton').bind('click',grid1.showChanges);//信息变更提示

    //初始化搜索框
    initsearch();

});
function taskDetail(){
	var selectRows=grid1.grid.datagrid('getSelections');
	if(selectRows.length>0){


		//1.先查询任务定义是差异分析还是统计
		$.easyui.loading();
		$.post("/simple/column/select_task_type_by_excel_config_id",[selectRows[0].compareConfigId],function(result){
			$.easyui.loaded();
			if(result.success){
				let taskType=result.data;
				if("difference"==taskType){
					parent.addTab("["+selectRows[0].id+"]任务详情","/compore/task.html?taskId="+selectRows[0].id);
				}else if("stat"==taskType){
					parent.addTab("["+selectRows[0].id+"]任务详情","/compore/task_stat.html?taskId="+selectRows[0].id);
				}else if("search"==taskType){
					parent.addTab("["+selectRows[0].id+"]任务详情","/compore/task_search.html?taskId="+selectRows[0].id);
				}
			}else{
				$.messager.alert("提示", "操作失败！<br>"+result.message);
			}
		});

	}else{
		$.messager.alert("提示", "请选择一条数据！");
	}

}

/**
 * 新增一行
 */
function addRow(){
//ROW
	var newRowData={id:guid()};//初始化行数据,creator_id:sessionuser.id,creator_name:sessionuser.nickname,create_time:moment().format('YYYY-MM-DD')
	grid1.grid.datagrid('append',newRowData);	
	//tab
	//parent.addTab("新增","/view/form.html");
}



function onDeleteRow(){
	gridConfirm(grid1.grid,"是否确认删除",deleteRow);
}
function deleteRow(row){
	$.post("/excelCompareTask/delete",JSON.stringify({"id":row.id}),function(result){
		if(result.success){
			$.messager.alert("提示", "删除成功！");
			grid1.load();
		}else{
			$.messager.alert("提示", "删除失败！<br>"+result.message);
		}
	});
}


/**
 * 初始化搜索条件
 */
function initsearch(){
	/*$('#search-product_class_id').combotree({
		panelHeight:'auto',
		icons: [{
			iconCls:'icon-clear',
			handler:function(){
				$('#search-product_class_id').combotree('clear');
			}
		}],
	    data:grid1.combotreeDatas.product_class_id
	});
	//初始化combobox例子
	*/
	$('#search-compareConfigId').combobox({
		panelHeight:'auto',
		editable:false,
		valueField:'codeValue',
		textField:'codeName',
		icons: [{
			iconCls:'icon-clear',
			handler:function(e){
				$(e.data.target).combobox('clear');
			}
		}],
		data:grid1.comboboxDatas.compareConfigId
	});
}
</script>
</body>
</html>